const { mysql } = require('../qcloud')

// 分类页的默认数据
async function menuList (ctx) {
    const menuList = await mysql('nideshop_category').where({
        'parent_id': 0
    }).select()

    ctx.state.data = {
        menuList
    }
}

// 分类页选择当前的分类
async function currentCategory (ctx) {
    const {id} = ctx.request.query

    const currentCategory = await mysql('nideshop_category').where({
        'parent_id': id
    }).select()

    ctx.state.data = {
        currentCategory
    }
}

module.exports = {
    menuList,
    currentCategory
}
